package com.jianglin.mapper;

import com.jianglin.model.Building;
import org.apache.ibatis.annotations.*;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
/**
 *
 *
 * @author liyijia
 */
@Mapper
@Component("buildingDao")
@SuppressWarnings("SpellCheckingInspection")
public interface BuildingMapper {

    @Select("<script>" +
            "SELECT * FROM building" +
            "<where>" +
            "   <if test='numbers != null and numbers != \"\"'>" +
            "       AND numbers LIKE CONCAT('%', #{numbers}, '%')" +
            "   </if>" +
            "</where>" +
            "</script>")
    List<Building> queryBuildAll(@Param("numbers") String numbers);

    @Select("SELECT * FROM building WHERE id = #{buildId}")
    Building queryBuildById(@Param("buildId") Integer buildId);


    @Select("SELECT * FROM building WHERE id = #{id}")
    Building selectById(Long id);

    @Insert("INSERT INTO building (numbers, uints, remarks) " +
            "VALUES (#{numbers}, #{uints}, #{remarks})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Building building);

    @Update("UPDATE building SET " +
            "numbers = #{numbers}, " +
            "uints = #{uints}, " +
            "remarks = #{remarks} " +
            "WHERE id = #{id}")
    int update(Building building);

    @Delete("DELETE FROM building WHERE id = #{id}")
    int deleteById(Long id);


    @Select("SELECT * FROM building")
    List<Building> selectAll();
}